angular.module('Controller')
.directive('binListCheckbox',[()->
    return {
        restrict:'E'
        replace:true
        scope:{
            value:'=binValue'
            list:'=binList'
        }
        templateUrl:'templates/common-directive/bin-list-checkbox/bin-list-checkbox.html'
        controller:'binListCheckboxCtrl'
    }
])

.controller 'binListCheckboxCtrl',(urls,$scope,wfAlert,userData,commonUtil,commonConstant,$http,$localStorage)->
    $scope.checkboxList=commonUtil.loadBinList($scope.value,$scope.list)
    $scope.$watch('checkboxList',(newList,old)->
        val=0
        _.each newList,(item)->
            if item.checked
                val+=item.value
        val=undefined if val==0
        $scope.value=val
    ,true)
